Skip to content

feat(linter): add unicorn/require-module-attributes rule#17166

Merged
camc314 merged 6 commits intooxc-project:mainfrom
baevm:unicorn/require-module-attributes
Dec 20, 2025
Merged

feat(linter): add unicorn/require-module-attributes rule#17166
camc314 merged 6 commits intooxc-project:mainfrom
baevm:unicorn/require-module-attributes

Conversation

@baevm
Copy link
Contributor

@baevm baevm commented Dec 20, 2025

this PR adds unicorn/require-module-attributes, issue #684

source doc
source code

Copilot AI review requested due to automatic review settings December 20, 2025 11:50
@baevm baevm requested a review from camc314 as a code owner December 20, 2025 11:50
@github-actions github-actions bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Dec 20, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new linter rule unicorn/require-module-attributes that enforces non-empty attribute lists in import/export statements and import() expressions. The rule detects cases where empty attribute objects ({}) or empty with clauses are used, which provide no useful metadata about module loading.

Key changes:

  • Implements detection for empty with clauses in import/export declarations
  • Implements detection for empty options objects and empty with properties in dynamic import expressions
  • Includes comprehensive test cases covering various edge cases including comments and parenthesized expressions

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
crates/oxc_linter/src/rules/unicorn/require_module_attributes.rs Main rule implementation with logic to detect empty attribute lists in imports/exports and comprehensive tests
crates/oxc_linter/src/rules.rs Module registration and rule declaration in the all_lint_rules macro
crates/oxc_linter/src/generated/rule_runner_impls.rs Generated rule runner implementation specifying which AST node types trigger the rule
crates/oxc_linter/src/snapshots/unicorn_require_module_attributes.snap Test snapshot showing expected diagnostic output for all failure cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 20, 2025

CodSpeed Performance Report

Merging #17166 will not alter performance

Comparing baevm:unicorn/require-module-attributes (cb85250) with main (c7cbe69)

Summary

✅ 4 untouched
⏩ 41 skipped1

Footnotes

  1. 41 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@baevm baevm force-pushed the unicorn/require-module-attributes branch from bffa846 to 9f33910 Compare December 20, 2025 11:58
@camc314 camc314 self-assigned this Dec 20, 2025
Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@camc314 camc314 merged commit 30fb206 into oxc-project:main Dec 20, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants